importPackage(net.sf.odinms.client);
importPackage(net.sf.odinms.server.maps);

var status = -1;

function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
        	cm.dispose();
	} else {
        	if (mode == 1) {
            		status++;
		} else {
            		status--;
        	}
        	if (status == 0) {
			if(cm.getChar().getMapId() == 980000000) {
				if (cm.getCharQuantity(980000100) >= 1) {
					cm.sendYesNo("There are #b" + cm.getCharQuantity(980000100) + " players waiting in room 1, wanna join?");
				} else if (cm.getCharQuantity(980000101) >= 1) {
					cm.sendOk("There is already a monstercarnival going on");
					cm.dispose();
				} else {
					cm.sendYesNo("There is no party in, do you want to create a room?");
				}
			} else {
				cm.sendSimple("What do you want to do?\r\n#L1#Go to the carnival PQ#l\r\n#L2#Trade #i4001129# for items#k#l");
			}
		} else if (status == 1) {
			if (cm.getChar().getMapId() == 980000000) {
				if (cm.getCharQuantity(980000100) >= 1) {
					cm.warp(980000100);
					cm.setBlue();
					cm.dispose();
				} else {
					cm.warp(980000100);
					cm.setRed();
					cm.dispose();
				}
			} else {
				if (selection == 1) {
					if (cm.getChar().getMapId() == 910000000) {
						//cm.getPlayer().saveLocation(SavedLocationType.MC);
						cm.warp(980000000);
						cm.dispose();
					} else {
						cm.getPlayer().saveLocation(SavedLocationType.MC);
						cm.warp(980000000);
						cm.dispose();
					}
				} else {
					if (cm.itemQuantity(4001129) >= 1) {
					cm.sendOk("Good, you have a maple coin\r\nI am still in #rTesting#k phase\r\nPlease come back later");
					cm.dispose();
				} else {
					cm.sendOk("You don't have an #i4001129#");
					cm.dispose();
				}
			}
		}
	}
}
}